package com.example.safehome;
import java.util.Random;

public class FireSensor
{

    //系统状态
    private static boolean systemStatus;

    //入侵地点
    private String firePosition;

    //是否发生火灾
    private static boolean isFire = false;

    //是否运行
    private static boolean isRunning = true;

    //入侵数组
    private String[]Position ={"阳台","客厅","卧室1","卧室2","卫生间1","卫生间2","饭厅","厨房"};


    FireSensor()
    {
        systemStatus=true;
        firePosition="";
    }
    //监测设备运行状态
    public boolean getStatus()
    {
        return systemStatus;
    }

    public boolean isOnFire() {
        return isFire;
    }

    //获取案发地点
    public String getFirePosition()
    {
        return firePosition;
    }

    //报警
    public void ringAlarm()
    {
        voiceWarn();
        callPolice();
        callHost();
    }

    //鸣响驱逐警报
    public void voiceWarn()
    {
        return;
    }

    //通知警察
    public void callPolice()
    {
        java.lang.System.out.println("拨打110");
    }

    //通知用户
    public void callHost()
    {

    }

    //火灾检测是否运行
    public boolean isDetect()
    {
        return isRunning;
    }

    //火灾检测是否退出
    public boolean isQuit()
    {
        return !isRunning;
    }

    //火灾检测
    public void detect()
    {
        if(getStatus())
        {
            isRunning=true;
            if(isFire)
            {
                getFirePosition();
                ringAlarm();
            }
        }
    }

    //退出火灾检测
    public void quit()
    {
        isRunning=false;
    }

    //测试生成火灾
    public void test(){
        Random RandomPosition = new Random();
        firePosition=Position[RandomPosition.nextInt(Position.length-1)];
        isFire=true;

    }

    //异常处理
    public boolean exceptionHandle()
    {
        return true;
    }


}
